Ext.define('AM.picker.Audio', {

    extend:'Ext.window.Window',

    title:'选择音乐',
    autoScroll:true,
    width:500,
    height:300,
    autoShow: true,

    listeners:{
        render:function () {
            var win = this;

            Ext.Ajax.request({
                url:'GetAudios',

                success:function (response) {
                    var text = response.responseText;
                    var names = text.split('|');
                    Ext.each(names, function (name) {
                        if (-1 != name.indexOf('.mp3') || -1 != name.indexOf('.wav')) {
                            var item = {
                                xtype:'button',
                                text:name,
                                handler:function () {
                                    var audio = Ext.create("AM.component.Audio", null, {'audio-name':name});
                                    AM.service.Insert._insert(audio);
                                }
                            }
                            win.add(item);
                        }

                    })



                }

            })

        },

        beforeclose: function() {
            this.hide();
            return false;
        }
    }


})